clc,clear all
close all

R1=240;
L=100e-6;

%tau=8.33e-7;

tau = L/R1;
T=tau/100;
t=0:T:(2000*tau);
%t=(0:5e3)*T;
N=length(t);

dw = 0.01;
w=2*pi*((dw:dw:1)*1e6);
K = nan(1, length(w));
Umas = nan(1, N);

for r=1:length(w);
    U=0;
    
    E=sin(w(r)*t);
    for k=1:N
        U=(T*E(k)+tau*U)/(tau+T);
        Umas(k)=U/2;
    end
    K(r) = (max(Umas(floor(k/2):k)) - min(Umas(floor(k/2):k)))/2;
    
end
figure(1)
plot(t,Umas)
xlabel('t, s');

figure(2)
plot(w/2/pi / 1e6,K)
xlabel('f, Mhz');